﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.DirectoryServices;
using HumanManagement.BusinessObjects;

namespace BSC_HumanManagement
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["login"].ToString() == "true")
            {
                UserControl _ucMenuLeft = LoadControl("~/UserControls/MenuLeft.ascx") as UserControl;
                this.plc_MenuLeft.Controls.Add(_ucMenuLeft);

                if (Request.QueryString["FunctionName"] != null)
                {
                    Load_ContentRight(Request.QueryString["FunctionName"]);
                }
                LoadMenuRight();
                //BSC_HumanManagement.Code.LdapAuthentication adAuth = new BSC_HumanManagement.Code.LdapAuthentication(Session["domainPath"].ToString());
                //List<Code.ADUser> lstADUsers = adAuth.GetADUsers();
            }
            else
            {
                Response.Redirect("Pages/Login.aspx");
            }
        }

        private void LoadMenuRight()
        {
            try
            {
                PersonalProfile _objPersonalProfile = (PersonalProfile)Session["PersonalInfomation"];
                this.lblHotenRight.Text = _objPersonalProfile.FullName;
                string base64String = Convert.ToBase64String(_objPersonalProfile.Picture, 0, _objPersonalProfile.Picture.Length);
                this.imgAnhDaiDienRight.ImageUrl = "data:image/jpeg;base64," + base64String;
            }
            catch (Exception ex) { }
        }

        private void Load_ContentRight(string _FunctionName)
        {
            UserControl _ucRightContent = null;
            switch (_FunctionName.Replace("%20",""))
            {
                #region ho so nhan vien
                case "Hồ sơ nhân viên":
                    _ucRightContent = LoadControl("UserControls/uc_HoSoNhanVien.ascx") as UserControl;
                    this.lblTitleFunction.Text = "Quản lý hồ sơ nhân viên";
                    break;
                case "Hồ sơ nhân viên Detail":
                    _ucRightContent = LoadControl("UserControls/uc_HoSoNhanVien_Detail.ascx") as UserControl;
                    this.lblTitleFunction.Text = "Quản lý hồ sơ nhân viên";
                    break;
                case "Hồ sơ nhân viên Edit":
                    _ucRightContent = LoadControl("UserControls/uc_HoSoNhanVien_Detail.ascx") as UserControl;
                    this.lblTitleFunction.Text = "Quản lý hồ sơ nhân viên";
                    break;
                case "Hồ sơ nhân viên Delete":
                    _ucRightContent = LoadControl("UserControls/uc_HoSoNhanVien_Detail.ascx") as UserControl;
                    this.lblTitleFunction.Text = "Quản lý hồ sơ nhân viên";
                    break;
                #endregion

                #region hop dong lao dong
                case "Hợp đồng lao động":
                    _ucRightContent = LoadControl("UserControls/uc_HopDongLaoDong.ascx") as UserControl;
                    break;
                case "Hợp đồng lao động Detail":
                    _ucRightContent = LoadControl("UserControls/uc_HopDongLaoDong_Detail.ascx") as UserControl;
                    break;
                case "Hợp đồng lao động Edit":
                    _ucRightContent = LoadControl("UserControls/uc_HopDongLaoDong_Detail.ascx") as UserControl;
                    break;
                case "Hợp đồng lao động Delete":
                    _ucRightContent = LoadControl("UserControls/uc_HopDongLaoDong_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Quá trình công tác
                case "Quá trình công tác":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhCongTac.ascx") as UserControl;
                    break;
                case "Quá trình công tác Detail":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhCongTac_Detail.ascx") as UserControl;
                    break;
                case "Quá trình công tác Edit":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhCongTac_Detail.ascx") as UserControl;
                    break;
                case "Quá trình công tác Delete":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhCongTac_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Quá trình bổ nhiệm
                case "Quá trình bổ nhiệm":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhBoNhiem.ascx") as UserControl;
                    break;
                case "Quá trình bổ nhiệm Detail":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhBoNhiem_Detail.ascx") as UserControl;
                    break;
                case "Quá trình bổ nhiệm Edit":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhBoNhiem_Detail.ascx") as UserControl;
                    break;
                case "Quá trình bổ nhiệm Delete":
                    _ucRightContent = LoadControl("UserControls/uc_QuaTrinhBoNhiem_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Tình trạng hôn nhân
                case "Tình trạng hôn nhân":
                    _ucRightContent = LoadControl("UserControls/uc_TinhTrangHonNhan.ascx") as UserControl;
                    break;
                case "Tình trạng hôn nhân Detail":
                    _ucRightContent = LoadControl("UserControls/uc_TinhTrangHonNhan_Detail.ascx") as UserControl;
                    break;
                case "Tình trạng hôn nhân Edit":
                    _ucRightContent = LoadControl("UserControls/uc_TinhTrangHonNhan_Detail.ascx") as UserControl;
                    break;
                case "Tình trạng hôn nhân Delete":
                    _ucRightContent = LoadControl("UserControls/uc_TinhTrangHonNhan_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Quan hệ gia đình
                case "Quan hệ gia đình":
                    _ucRightContent = LoadControl("UserControls/uc_QuanHeGiaDinh.ascx") as UserControl;
                    break;
                case "Quan hệ gia đình Detail":
                    _ucRightContent = LoadControl("UserControls/uc_QuanHeGiaDinh_Detail.ascx") as UserControl;
                    break;
                case "Quan hệ gia đình Edit":
                    _ucRightContent = LoadControl("UserControls/uc_QuanHeGiaDinh_Detail.ascx") as UserControl;
                    break;
                case "Quan hệ gia đình Delete":
                    _ucRightContent = LoadControl("UserControls/uc_QuanHeGiaDinh_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Điện thoại liên lạc
                case "Điện thoại liên lạc":
                    _ucRightContent = LoadControl("UserControls/uc_DienThoaiLienLac.ascx") as UserControl;
                    break;
                case "Điện thoại liên lạc Detail":
                    _ucRightContent = LoadControl("UserControls/uc_DienThoaiLienLac_Detail.ascx") as UserControl;
                    break;
                case "Điện thoại liên lạc Edit":
                    _ucRightContent = LoadControl("UserControls/uc_DienThoaiLienLac_Detail.ascx") as UserControl;
                    break;
                case "Điện thoại liên lạc Delete":
                    _ucRightContent = LoadControl("UserControls/uc_DienThoaiLienLac_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Khả năng ngoại ngữ
                case "Khả năng ngoại ngữ":
                    _ucRightContent = LoadControl("UserControls/uc_KhaNangNgoaiNgu.ascx") as UserControl;
                    break;
                case "Khả năng ngoại ngữ Detail":
                    _ucRightContent = LoadControl("UserControls/uc_KhaNangNgoaiNgu_Detail.ascx") as UserControl;
                    break;
                case "Khả năng ngoại ngữ Edit":
                    _ucRightContent = LoadControl("UserControls/uc_KhaNangNgoaiNgu_Detail.ascx") as UserControl;
                    break;
                case "Khả năng ngoại ngữ Delete":
                    _ucRightContent = LoadControl("UserControls/uc_KhaNangNgoaiNgu_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Chuyên môn
                case "Chuyên môn":
                    _ucRightContent = LoadControl("UserControls/uc_ChuyenMon.ascx") as UserControl;
                    break;
                case "Chuyên môn Detail":
                    _ucRightContent = LoadControl("UserControls/uc_ChuyenMon_Detail.ascx") as UserControl;
                    break;
                case "Chuyên môn Edit":
                    _ucRightContent = LoadControl("UserControls/uc_ChuyenMon_Detail.ascx") as UserControl;
                    break;
                case "Chuyên môn Delete":
                    _ucRightContent = LoadControl("UserControls/uc_ChuyenMon_Detail.ascx") as UserControl;
                    break;
                #endregion

                #region Túi hồ sơ
                case "Túi hồ sơ":
                    _ucRightContent = LoadControl("UserControls/uc_TuiHoSo.ascx") as UserControl;
                    break;
                case "Túi hồ sơ Detail":
                    _ucRightContent = LoadControl("UserControls/uc_TuiHoSo_Detail.ascx") as UserControl;
                    break;
                case "Túi hồ sơ Edit":
                    _ucRightContent = LoadControl("UserControls/uc_TuiHoSo_Detail.ascx") as UserControl;
                    break;
                case "Túi hồ sơ Delete":
                    _ucRightContent = LoadControl("UserControls/uc_TuiHoSo_Detail.ascx") as UserControl;
                    break;
                #endregion

                default:
                    break;
            }
            this.plc_ContentRight.Controls.Add(_ucRightContent);
        }
    }
}